// written by Ray Zeller

#ifndef COMPARATOR_H_
#define COMPARATOR_H_
#include "event.h"
#include <vector>
using namespace std;


template <class T>
class SortEvent
{
  public:
  	virtual ~SortEvent () {}
    virtual bool isLess(T lhs, T rhs ) const = 0;
};

/**
 * Compare object: ordering by length.
 * Uses inheritance to implement what is effectively an interface.
 */

template <class T>
class Comparitor
{
	public:
		Comparitor (SortEvent<T> * comparison):
		myComparison(comparison)
		{}
		
		bool operator() (T lhs,T rhs) const
		{
			return myComparison->isLess(lhs, rhs);
		}
	private:
		SortEvent<T> * myComparison;
};

template <class T>
struct Sorter : public SortEvent<T>
{
  public:
    virtual bool isLess(T lhs,T  rhs ) const
      { 
      	if(lhs->getDay()==rhs->getDay())
      		return lhs->getStart( ) < rhs->getStart( );
      	else
      		return lhs->getDay() < rhs->getDay();
      }
};

#endif /*COMPARATOR_H_*/
